package com.orientechnologies.orient.core.sql.executor;

import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.sql.executor.stream.OExecutionStream;
import java.util.List;
import java.util.Set;

/** Created by luigidellaquila on 06/07/16. */
public interface OInternalExecutionPlan extends OExecutionPlanContextOps {

  public static final String JAVA_TYPE = "javaType";

  /**
   * if the execution can still return N elements, then the result will contain them all. If the
   * execution contains less than N elements, then the result will contain them all, next result(s)
   * will contain zero elements
   * @param ctx TODO
   *
   * @return
   */
  OExecutionStream start(OCommandContext ctx);

  long getCost();

  default OResult serialize() {
    throw new UnsupportedOperationException();
  }

  default void deserialize(OResult serializedExecutionPlan) {
    throw new UnsupportedOperationException();
  }

  default OInternalExecutionPlan copy(OCommandContext ctx) {
    throw new UnsupportedOperationException();
  }

  boolean canBeCached();

  String getStatement();

  void setStatement(String stm);

  String getGenericStatement();

  void setGenericStatement(String stm);

  String prettyPrint(OPrintContext ctx);

  OResult toResult(OToResultContext ctx);

  List<OExecutionStepInternal> getSteps();

  Set<String> getIndexes();

  default boolean isExplain() {
    return false;
  }
}
